﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 坦克大战
{
    abstract class Engine
    {
        public int power = 0;
        public int speed = 0;
        abstract public void Work();
    }
    class SpeedEngine : Engine
    {
        public SpeedEngine()
        {
            power = 2;
            speed = 100;
        }
        override public void Work()
        {
            Console.WriteLine("Speed:" + speed);
        }
    }
    class HeavyEngine : Engine
    {
        public HeavyEngine()
        {
            power = 10;
            speed = 50;
        }
        override public void Work()
        {
            Console.WriteLine("Speed:" + speed);
        }
    }
    class Tank
    {
        private Engine engine = null;

        public Tank(Engine engine)
        {
            this.engine = engine;
        }

        public void Run()
        {
            engine.Work();
        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {
            SpeedEngine se = new SpeedEngine();
            Tank tank = new Tank(se);
            tank.Run();

            Console.Read();
        }
    }
}
